import { ActionType } from "@ant-design/pro-components";
import { PageContainer } from "@ant-design/pro-layout";
import ProTable from "@ant-design/pro-table";
import { useParams } from "@sker/sdk";
import { renderAdminPage } from "@sker/ui";
import { Button, Popconfirm, Input, Alert } from "antd";
import { useRef } from "react";

export const DevingPage: React.FC<{}> = ({ }) => {
    const actionRef = useRef<ActionType>()
    const { params, setParams, search } = useParams<any>({})
    return <PageContainer title={'数据字典'} content={<>
        <Alert description={'数据字典为系统内置，不允许删除和新增，只可修改！'} type='warning' />
        <div className="flex mt-12px">
            <Input className="w-180px" placeholder="请输入关键字" onChange={e => {
                setParams({ keyword: e.target.value })
            }} />
            <Button className="ml-12px" type={'primary'} onClick={e=>{
                search()
            }}>搜索</Button>
            <div className="flex-1"></div>
        </div>
    </>}>
        <ProTable
            search={false}
            toolBarRender={false}
            actionRef={actionRef}
            params={params}
            columns={[
                { title: '代号' },
                { title: '所属' },
                { title: '备注' },
                { title: '中文' },
                { title: '英文' },
                {
                    title: '操作', align: 'right', renderText(text, record, index, action) {
                        return <>
                            <Button size={'small'} type={'link'} onClick={e => {
                            }}>编辑</Button>
                            <Popconfirm onConfirm={async e => {
                                await actionRef.current?.reload();
                            }} title={'此操作不可逆!您确定要执行此操作吗？'} description={'删除后无法恢复，请慎重操作！！'}>
                                <Button size={'small'} type={'link'} danger>删除</Button>
                            </Popconfirm>
                        </>
                    },
                },
            ]} />
    </PageContainer>
}

renderAdminPage(DevingPage, 'imeepos/core/web/code')
